# Copyright(C) 2022. Huawei Technologies Co.,Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import numpy as np

file1 = open('../output_V1.txt', mode='r', encoding='UTF-8')
file2 = open('../output_V2.txt', mode='r', encoding='UTF-8')
output_V1 = []
output_V2 = []
contents1 = file1.readlines()
contents2 = file2.readlines()
for msg1 in contents1:
    msg1 = msg1.strip('\n')
    out_V1 = msg1.split(' ')
    output_V1.append(list(map(float, out_V1)))
file1.close()
for msg2 in contents2:
    msg2 = msg2.strip('\n')
    out_V2 = msg2.split(' ')
    output_V2.append(list(map(float, out_V2)))
file2.close()
output_V1 = np.array(output_V1)
output_V2 = np.array(output_V2)
result = (abs(output_V1 - output_V2)) / output_V1
result = 1 - sum(result) / len(result)
print(result)
